function [PQcurve, SampleInfo] = LoadAllocate(LoadProfilePaths, ratedPQs, PQdurations)
    %LoadAllocate 依据输入曲线进行抽样形成负荷点时序曲线
    %LoadAllocate(LoadProfilePaths, ratedPQs, PQdurations)
    %LoadAllocate(SampleInfo, ratedPQs, PQdurations)
    %LoadProfilePaths，每条csv曲线的路径
    %SampleInfo，结构体，抽样信息
    %ratedPQs，表格，包含负荷点额定负荷有功、无功、用户数量
    %PQdurations，duration数组，确定需要哪个时间点的功率

    %% 曲线抽样
    if isvector(PQdurations) || isscalar(PQdurations)

        if ~isrow(PQdurations)
            PQdurations = PQdurations.';
        end

    else
        error('仅支持duration向量输入');
    end
    
    if isstruct(LoadProfilePaths)
        SampleInfo = LoadProfilePaths;
    else
        SampleInfo = LoadProfilesSampler(LoadProfilePaths, ratedPQs.users);
    end
    
    %% 曲线插值
    SampleInfo.interpolation = zeros(SampleInfo.Nprofile, length(PQdurations));

    for k = 1:SampleInfo.Nprofile
        [query_data, PQdurations] = query_loadprofile(SampleInfo.profiles(k).time, SampleInfo.profiles(k).mult, PQdurations, 0, 1);
        SampleInfo.interpolation(k, :) = query_data;
    end

    SampleInfo.durations = PQdurations;

    %% 分配功率
    PQcurve = cell(height(ratedPQs), 1);

    for k = 1:height(ratedPQs)
        curve = diag([ratedPQs.P(k) ratedPQs.Q(k)]./ ratedPQs.users(k))  * ones(2, ratedPQs.users(k));
        curve = curve * SampleInfo.interpolation(SampleInfo.choices{k}, :);
        PQcurve{k} = curve;
    end

end
